home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 34
/
Amiga Format CD34 (1998-11-20)(Future Publishing)(GB)[!][Christmas issue].iso
/
-seriously_amiga-
/
programming
/
basic
/
blitzc2p
/
game
/
rupture
/
display.ascii
next >
Wrap
Text File
|
1998-10-01
|
26KB
|
1,106 lines
;Display
Statement Permit{}
;Permit multitasking, only if it is globally intended
SHARED Multitasking.b
If Multitasking Then Permit_
End Statement
Statement Forbid{}
;Disable multitasking, if it isn't globally intended
SHARED Multitasking.b
If Multitasking Then Forbid_
End Statement
Statement Multitasking{State.b}
;Toggle global multitasking on or off.
SHARED Multitasking.b
If State
If Multitasking=False Then Permit_
Else
If Multitasking Then Forbid_
EndIf
Multitasking=State
End Statement
Statement InitC2P{A.l,B.l,C.l,D.b}
;Initialises chunky-to-planar
;A.l=d0=Chunky Width
;B.l=d1=Chunky Height
;C.l=d2=Chunky Yoffset (Top)
;D.b=d3=Processor (blitz instruction, will be 0/1/2/3/4)
LEA c2p_Data(pc),a0
ANDI.l #$ffff,d0
MULU.w d0,d2
LSR.l #3,d2 ; bytes
MOVE.l d2,c2p_ScrOffs-c2p_Data(a0) ; Planar Y offset
MULU.w d0,d1
MOVE.l d1,c2p_Pixels-c2p_Data(a0)
CMP.b #4,d3 ; 040+?
BNE c2pIlowCPU
MOVE.b #1,c2pCPUmode
BRA c2pIskip
c2pIlowCPU
MOVE.b #0,c2pCPUmode
c2pIskip
AsmExit
End Statement
Statement ChunkyClearscreen4{ChunkyBuf.l,BufHeight.w,OpWidth.w,DestWidth.w,Value.l}
;Clears the rightmost 4-pixel-width column in the chunky buffer to Value.l
;Covers up the longword clip/wrap buffer. Column is rightmost to OpWidth, DestWidth supplies modulo
MOVE.l d0,a0 ; Chunky output
AND.l #$FFFF,d1 ; Only word
SUBQ.l #1,d1 ; Loopcounter
AND.l #$FFFF,d3 ; Modulo
SUBQ.l #4,d3 ; Modulo-4 to accomodate move.l
AND.l #$FFFF,d2 ; Only word
SUBQ.l #4,d2 ; OpWidth-4, x start position
ADD.l d2,a0 ; Source position
ChunkyClear4
MOVE.l d4,(a0)+ ; Clear 4 pixels
ADD.l d3,a0 ; Dest Modulo
DBRA d1,ChunkyClear4
AsmExit
End Statement
Statement ChunkyClearscreen32{ChunkyBuf.l,BufHeight.w,Value.l,Width.w}
;Clears chunky screen, Width*BufHeight pixels (Width multiples of 32!)
MOVE.l a3,-(a7)
MOVE.l d0,a0 ; Chunky output
MOVE.l d2,d0 ; Get value
AND.l #$FFFF,d3 ; Only word
MOVE.l d3,d2 ; Width
AND.l #$FFFF,d1 ; Only word
MULU d1,d2 ; Size in bytes
ADD.l d2,a0 ; To end of buffer
SUBQ.l #1,d1 ; Init YLoop
EXG.l d0,d3 ; 1
MOVE.l d3,d4 ; 2
MOVE.l d3,d5 ; 3
MOVE.l d3,d6 ; 4
MOVE.l d3,d7 ; 5
MOVE.l d3,a1 ; 6
MOVE.l d3,a2 ; 7
MOVE.l d3,a3 ; 8 longwords = 32 pixels
LSR.w #2+3,d0 ; Width in longwords (2=2^2=4=longwords, 3=2^3=8=groups of 8 longwords)
SUBQ.l #1,d0 ; Xloopcounter
ChunkyClrLoopY
MOVE.l d0,d2 ; Init XLoop
ChunkyClrLoopX
MOVEM.l d3-d7/a1-a3,-(a0) ; Clear 32 pixels
DBRA d2,ChunkyClrLoopX
DBRA d1,ChunkyClrLoopY
MOVE.l (a7)+,a3
AsmExit
End Statement
Statement ChunkyCopy16{ChunkyBufA.l,ChunkyBufB.l,BufHeight.w,CPU.b,OpWidth.w,DestWidth.w}
;Copies one chunky screen to another, Width*BufHeight pixels (Width multiples of 16!)
;Seperate routines for 040+ (move16) and 030- (movem)
;Width of source buffer and dest buffer will be the same and use the same modulo but OpWidth can be narrower
MOVE.l d0,a0 ; Chunky source
MOVE.l d1,a1 ; Chunky destination
MOVE.w d2,d0 ; Height
AND.l #$FFFF,d0 ; Only word
SUBQ.l #1,d0 ; d0=YLoop
AND.l #$FFFF,d4 ; Only word
AND.l #$FFFF,d5 ; Only word
SUB.l d4,d5 ; Dest modulo
LSR.w #2+2,d4 ; Longwords (2=2^2=4=longwords, 2=2^2=4=groups of 4 longwords
SUBQ.l #1,d4 ; loop
MOVE.l d4,d1 ; d1=XLoop
MOVE.l d5,d2 ; d2=Dest Modulo
CMP.b #4,d3 ; 040+?
BEQ ChunkyCopy040 ; Yes, do move16's
ADD.l #16,a1
ChunkyCopy030
ChunkyCopy030y
MOVE.l d1,d3 ; d3=Xloop
ChunkyCopy030x
MOVEM.l (a0)+,d4-d7
MOVEM.l d4-d7,-(a1) ; 16 pixels
ADD.l #32,a1
DBRA d3,ChunkyCopy030x
ADD.l d2,a0 ; Source modulo
ADD.l d2,a1 ; Dest modulo
DBRA d0,ChunkyCopy030y
AsmExit
ChunkyCopy040
ChunkyCopy040y
MOVE.l d1,d3 ; d3=Xloop
ChunkyCopy040x
Dc.l $F6209000 ; move16 (a0)+,(a1)+ ; 16 bytes
DBRA d3,ChunkyCopy040x
ADD.l d2,a0 ; Source modulo
ADD.l d2,a1 ; Dest modulo
DBRA d0,ChunkyCopy040y
AsmExit
End Statement
Function.b InitDisplay{Title$}
;Creates a display
;Title$=The screen title (not displayed)
SHARED PrefDisplayHeight.w,PrefDisplayID.l,PrefDisplayBuffering.b,ChunkyHeight.w,*ScrVP.ViewPort,IsAGA.b
SHARED ChunkyBase.l,ChunkyBuffer.l,LandBuffer.l,GameHeight.w,PrefDisplayLeft.w,PrefDisplayTop.w
SHARED PrefDisplayDepth.w,ChunkyWidth.w,PrefDisplayWidth.w,DisplaySplit.w,GameWidth.w
SHARED GameChunkyWidth.w,GameChunkyHeight.w
;Open a test screen first to a) test for AGA or GFX-Card, and b) because the dimensions might be
;too large to open a chipram screen, and the dimensions for AGA have not yet been reduced to within limits
Dim ScrTags.TagItem(13)
Rect.Rectangle\MinX=0,0,320,240 ; For test
ScrTags(0)\ti_Tag=#SA_Width,320 ; For test
ScrTags(1)\ti_Tag=#SA_Height,240; For test
ScrTags(2)\ti_Tag=#SA_Depth,PrefDisplayDepth
ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
ScrTags(4)\ti_Tag=#SA_Type,$F
ScrTags(5)\ti_Tag=#SA_Quiet,True
ScrTags(6)\ti_Tag=#SA_ShowTitle,False
ScrTags(7)\ti_Tag=#SA_Behind,True
ScrTags(8)\ti_Tag=#SA_DClip,&Rect ; For test
ScrTags(9)\ti_Tag=#SA_Exclusive,True
ScrTags(10)\ti_Tag=#SA_Draggable,False
ScrTags(11)\ti_Tag=#SA_AutoScroll,True
ScrTags(12)\ti_Tag=#TAG_DONE,0
ScrTags(13)\ti_Tag=#TAG_DONE,0
InitShape 0,16,1,2 ; Mouse pointer 16x1 (transparent)
UsedChip.l=(320 LSR 3)*PrefDisplayDepth*240 ; With test params
FreeChip.l=AvailMem_(#MEMF_CHIP)
Forbid{}
If ScreenTags(0,Title$,&ScrTags(0))<>0 ; Test for GFX-Card or AGA
NowChip.l=AvailMem_(#MEMF_CHIP)
Permit{}
If FreeChip-NowChip<UsedChip
; Graphics card screen
IsAGA=False
ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight*PrefDisplayBuffering
ScrTags(8)\ti_Tag=#SA_DClip,&Rect
VWait 25 ; seems to be necessary (safer)
Free Screen 0
VWait 10 ; just to be on the safe side
If ScreenTags(0,Title$,&ScrTags(0))<>0
For Loop.w=0 To PrefDisplayBuffering-1
If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
If Window(Loop,0,PrefDisplayHeight*Loop,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
WPointer 0
Menus Off
ScreensBitMap 0,Loop
*TmpBmp.bitmap=Addr BitMap(Loop)
Offset.l=*TmpBmp\_ebwidth*(PrefDisplayHeight*Loop)
For DLoop.w=0 To PrefDisplayDepth-1
*TmpBmp\_data[DLoop]=*TmpBmp\_data[DLoop]+Offset
Next DLoop
Next Loop
Else
Function Return False
EndIf
Else
; AGA screen
IsAGA=True
PrefDisplayWidth AND $FFC0 ; For AGA, width to nearest 64
If (PrefDisplayWidth*PrefDisplayHeight) LSR 3>#PlaneSize
PrefDisplayHeight=Int(#PlaneSize/(PrefDisplayWidth LSR 3))
EndIf
ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight ; Seperate buffers
ScrTags(8)\ti_Tag=#SA_DClip,&Rect
Forbid{}
VWait 25 ; seems to be necessary (safer)
Free Screen 0
For Loop.w=0 To PrefDisplayBuffering-1
If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
If AvailMem_(#MEMF_CHIP)>=(#PlanarWidth*#PlanarHeight)+16
Memory.l=AllocMem((#PlanarWidth*#PlanarHeight)+16,$10002) ; Chip bitmap
Memory=(Memory+16) AND $FFFFFFF0 ; Align for move16's
If Memory<>0
CludgeBitMap Loop,#PlanarWidth,#PlanarHeight,PrefDisplayDepth,Memory
*TmpBmp.bitmap=Addr BitMap(Loop)
*TmpBmp\_height=PrefDisplayHeight ; Force display height
*TmpBmp\_ebwidth=PrefDisplayWidth LSR 3 ; Force display width
*TmpBmp\_bitplanemod=((#PlanarWidth*#PlanarHeight)-(PrefDisplayWidth*PrefDisplayHeight)) LSR 3 ; Force plane modulo
If Loop=0
ScrTags(12)\ti_Tag=#SA_BitMap,Addr BitMap(0)
If ScreenTags(0,Title$,&ScrTags(0))=0
Permit{}